<?php
	if (isset($_POST['query']))
	{
		$user = 'root';
		$pass = '';
		$host = 'localhost';
		$db = 'examplecom';

		$connect = mysql_connect($host, $user, $pass);
		$select = mysql_select_db($db, $connect);

		$query = $_POST['query'];
		$mysql_query = mysql_query("SELECT * FROM category WHERE name LIKE '%{$query}%'");

		while ($row = mysql_fetch_assoc($mysql_query)) {
			$array[] = $row['name'];
		}

		echo json_encode($array);
	}
?>